home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / basic / PureBasic_Upd.lha / PureBasic_Update1.60 / PureBasic / Examples / Sources / Program1.pb < prev    next >
Encoding:
Text File  |  2000-09-10  |  2.8 KB  |  133 lines

  1. ;
  2. ; Example program for the PureBasic programming langage
  3. ;
  4. ; Coded by AlphaSND - © 1999 Fantaisie Software
  5. ;
  6. ;
  7. ; 02/07/2000
  8. ;   Modified a bit to support the new gadget library features
  9. ;
  10. ; 26/06/1999
  11. ;   First version
  12. ;
  13.  
  14. WbStartup()             ; This program can be started from the Workbench
  15.  
  16. InitWindow (1)          ; All init stuffs
  17. InitTagList(0)          ;
  18. InitGadget (0)          ;
  19. InitScreen (0)          ;
  20. InitRequester()
  21.  
  22. FindScreen(0,"")        ; Catch the frontmost screen..
  23.  
  24. Dim texts.s(4)
  25.  
  26. ; Now, create our window layout, fully font sensitive. To achieve that,
  27. ; we have 3 variables:
  28. ;
  29. ;   HFont   : To have the height of used gadget font
  30. ;   HGadget : Our default gadget height
  31. ;   DistGad : Our default distance between 2 gadgets (height only)
  32. ;
  33. ; With these, we can manipulate the gadget position very easely.
  34. ;
  35.  
  36. If CreateGadgetList(0,ScreenID())
  37.  
  38.   HFont   = ScreenFontHeight()
  39.   HGadget = HFont+6
  40.   DistGad = HGadget+4
  41.  
  42.   HG = HFont+10
  43.  
  44.   ButtonGadget(3, 10, HG, 200, HGadget, "File Requester"  , 0) : HG = HG+DistGad
  45.   ButtonGadget(4, 10, HG, 200, HGadget, "Font Requester"  , 0) : HG = HG+DistGad
  46.   ButtonGadget(5, 10, HG, 200, HGadget, "Screen Requester", 0) : HG = HG+DistGad+HFont+3
  47.  
  48.   PaletteGadget(2, 10, HG, 200, HGadget, "", 2, 0) : HG = HG+DistGad
  49.   
  50.   texts(0) = "This is"
  51.   texts(1) = "A cool"
  52.   texts(2) = "PureBasic"
  53.   texts(3) = "Example"
  54.   
  55.   CycleGadget(6, 100, HG, 100, HGadget, "Test :", texts(), 0) : HG = HG+DistGad+4
  56.   
  57.   ButtonGadget(0,  10, HG, 96, HGadget, "Ok", 0)
  58.   ButtonGadget(1, 115, HG, 96, HGadget, "Cancel", 0) : HG+HFont
  59.  
  60. endif
  61.  
  62. Title.s = "PureBasic Test !"
  63.  
  64. ResetTagList(#WA_Title,Title)
  65. If OpenWindow(0,100,100,215, HG+4, #WFLG_DRAGBAR | #WFLG_CLOSEGADGET, TagListID())
  66.  
  67.   AttachGadgetList(0, WindowID())
  68.  
  69.   Repeat
  70.     Repeat
  71.       VWait()
  72.       Event.l = WindowEvent()
  73.  
  74.     Until Event<>0
  75.  
  76.     If Event = #IDCMP_GADGETUP
  77.  
  78.       Select EventGadget()
  79.  
  80.         Case 0
  81.           Event = #IDCMP_CLOSEWINDOW
  82.  
  83.         Case 1
  84.           Event = #IDCMP_CLOSEWINDOW
  85.  
  86.         Case 2
  87.           PrintN("Palette gadget: "+Str(EventCode()))
  88.  
  89.         Case 3
  90.           PrintN("File Requester: '"+FileRequester(0)+"'")
  91.  
  92.         Case 4
  93.           FontRequester(0)
  94.  
  95.         Case 5
  96.           ScreenRequester(0)
  97.  
  98.         case 6
  99.           PrintN("Cycle gadget: "+Str(EventCode()))
  100.  
  101.           If EventCode() = 2
  102.             GoSuB Surprise
  103.           Endif
  104.  
  105.       EndSelect
  106.  
  107.     Endif
  108.  
  109.   Until Event = #IDCMP_CLOSEWINDOW
  110. Else
  111.   PrintN("Error, I can't open the window")
  112. Endif
  113.  
  114. End
  115.  
  116.  
  117. Surprise:
  118.  
  119.   SurpriseTitle.s = "Surprise ! :-)"
  120.   ResetTagList(#WA_Title, SurpriseTitle)
  121.   If OpenWindow(1,200,200,200,30,#WFLG_DRAGBAR | #WFLG_CLOSEGADGET, TagListID())
  122.  
  123.     Repeat
  124.       VWait()
  125.       Event.l = WindowEvent()
  126.     Until Event = #IDCMP_CLOSEWINDOW
  127.  
  128.     CloseWindow(1)
  129.     Event = 0
  130.   Endif
  131.  
  132. Return
  133.